package com.it.Service.impl;

import com.it.Mapper.PassengerMapper;
import com.it.Service.PassengerService;
import com.it.pojo.Passenger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PassengerServiceImpl implements PassengerService {
    @Autowired
    private PassengerMapper passengerMapper;

    @Override
    public List<Passenger> getPassenger(String username) {
        return passengerMapper.getPassenger(username);
    }

    @Override
    public void addPassenger(Passenger passenger, String username) {
        if(passengerMapper.getPassengerById(passenger.getIdNumber())==null){
            passengerMapper.addPassenger(passenger,username);
        }
        passengerMapper.addBind(passenger,username);
    }

    @Override
    public void deletePassenger(String idNumber) {
        passengerMapper.deletePassenger(idNumber);
    }

    @Override
    public Passenger getPassengerById(String idNumber) {
        return passengerMapper.getPassengerById(idNumber);
    }

    @Override
    public void updatePassenger(Passenger passenger) {
        passengerMapper.updatePassenger(passenger);
    }

    @Override
    public Passenger getIdentity(String username) {
        return passengerMapper.getIdentity(username);
    }
}
